package com.example.liuxing.jdmall.adpater;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.liuxing.jdmall.R;
import com.example.liuxing.jdmall.bean.RGetYourFav;
import com.example.liuxing.jdmall.bean.RSecoundKill;
import com.example.liuxing.jdmall.constant.NetworkConstant;
import com.loopj.android.image.SmartImageView;

/**
 * Created by liuxing on 2017/8/3.
 */

public class RecommendAdapter extends JDBaseAdpater {
    public RecommendAdapter(Context context) {
        super(context);
    }

    class ViewHolder {
        SmartImageView smartImageView;
        TextView nameTv;
        TextView priceTv;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        RecommendAdapter.ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.home_recommend_gv_item, parent, false);
            viewHolder = new RecommendAdapter.ViewHolder();
            viewHolder.smartImageView = (SmartImageView)convertView.findViewById(R.id.recommend_image_iv);
            viewHolder.nameTv = (TextView)convertView.findViewById(R.id.name_tv);
            viewHolder.priceTv = (TextView)convertView.findViewById(R.id.price_tv);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (RecommendAdapter.ViewHolder)convertView.getTag();
        }
        // 赋值
        RGetYourFav bean = (RGetYourFav) mdatas.get(position);
        viewHolder.smartImageView.setImageUrl(NetworkConstant.BASE_URL + bean.getIconUrl());
        viewHolder.nameTv.setText(bean.getName());
        viewHolder.priceTv.setText("￥" + bean.getPrice());
        return convertView;
    }
}
